package com.hongning.railway.ui.dynamic_photo;

import android.arch.lifecycle.ViewModelProviders;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.hongning.railway.R;
import com.hongning.railway.app.AppViewModelFactory;
import com.hongning.railway.app.Constant;
import com.hongning.railway.databinding.FragmentDynamicPhotoBinding;
import com.hongning.railway.entity.resbean.ResDynamicBean;

import me.goldze.mvvmhabit.BR;
import me.goldze.mvvmhabit.base.BaseFragment;
import me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapter;

public class DynamicPhotoFragment extends BaseFragment<FragmentDynamicPhotoBinding,DynamicPhotoFragmentViewModel> {
    ResDynamicBean.DataBean resDynamicBean;
    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.fragment_dynamic_photo;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public DynamicPhotoFragmentViewModel initViewModel() {
        AppViewModelFactory appViewModelFactory = AppViewModelFactory.getInstance(getActivity().getApplication());
        return ViewModelProviders.of(this,appViewModelFactory).get(DynamicPhotoFragmentViewModel.class);
    }

    @Override
    public void initParam() {
        super.initParam();
        resDynamicBean = getArguments().getParcelable(Constant.EXTRA_DATA);
    }

    @Override
    public void initData() {
//        binding.rvContent.setAdapter(new BindingRecyclerViewAdapter());
        binding.includeTitle.ivLeft.setVisibility(View.VISIBLE);
        binding.includeTitle.ivLeft.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getActivity().finish();
            }
        });
        binding.includeTitle.tvTopTitle.setText("活动相册");
        if (resDynamicBean!=null){
            viewModel.dynamicData.set(resDynamicBean);
            viewModel.getDynamicPhotos(resDynamicBean.getNewsId());
        }

    }
}
